//
//  UITableView+Category.m
//  ChengHuiTong
//
//  Created by CHT-Technology on 2017/1/12.
//  Copyright © 2017年 张文权. All rights reserved.
//

#import "UITableView+Category.h"
#import "UIImage+GIF.h"
@implementation UITableView (Category)

- (void)addGifHeaderWithRefreshingBlock:(void (^)())block{
    
    MJRefreshGifHeader *gifHeader = [MJRefreshGifHeader headerWithRefreshingBlock:^{
        
        if (block) {
            block();
        }
    }];
    
    [gifHeader.lastUpdatedTimeLabel setValue:@(YES) forKey:@"hidden"];
    [gifHeader.stateLabel setValue:@(YES) forKey:@"hidden"];
    
    
    UIImage *imagegif = [UIImage sd_animatedGIFNamed:@"jixiangwu"];
    
    NSArray *imagesArr = imagegif.images;
//    NSMutableArray *imagesArr = [NSMutableArray array];
//    [imagesArray enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
//        UIImage *image = (UIImage *)obj;
//        [imagesArr addObject:[LGToolMethods imageWithImage:image scaledToSize:CGSizeMake(75, 77)]] ;
//    }];
    
    //    NSArray *imagesPull = [imagesArr subarrayWithRange:NSMakeRange(44, 6)];
    // 设置普通状态的动画图片
    [gifHeader setImages:imagesArr forState:MJRefreshStateIdle];
    // 设置即将刷新状态的动画图片（一松开就会刷新的状态）
    [gifHeader setImages:imagesArr forState:MJRefreshStatePulling];
    // 设置正在刷新状态的动画图片
    [gifHeader setImages:imagesArr forState:MJRefreshStateRefreshing];
    
    self.header = gifHeader;
    
    self.backgroundColor = UIColorFromRGB(0xf5f5f5);
    
}

@end
